<template>
  <div>
    <a-table size="small" bordered :data-source="tableData" :pagination="false">
      <a-table-column key="zip" data-index="zip" align="center">
        <span slot="title">账期</span>
        <template slot-scope="text, record">
          <div>{{ record.zip.fileName }}</div>
          <a href="javascript:;" @click="downloadZip(record.zip)">打包下载</a>
        </template>
      </a-table-column>
      <a-table-column key="excelList" data-index="excelList" align="center">
        <span slot="title">账单下载</span>
        <template slot-scope="text, record">
          <div
            v-for="(item, index) in record.excelList"
            :key="index"
            style="display: flex; margin-bottom: 10px"
          >
            <span style="width: 120px">
              {{ item.sysStoreHouseCode }}
            </span>
            <a href="javascript:;" @click="downloadXlsx(item)">
              {{ item.fileName }}</a
            >
          </div>
        </template>
      </a-table-column>
    </a-table>
  </div>
</template>

<script>
import {
  warehouse_getFileList,
  warehouse_downloadFile,
} from "@/apis/system/FinanceManagement/warehouseBill";
import req from "@/utils/req";
export default {
  data() {
    return {
      tableData: [],
    };
  },
  mounted() {
    this.getTableList();
  },
  methods: {
    async getTableList() {
      let res = await warehouse_getFileList();
      if (res.code == "200") {
        this.tableData = res.responseBody;
      }
    },
    //下载账期
    async downloadZip(row) {
      let res = await warehouse_downloadFile(row.byBillFileId);
      req.exportZIP(row.fileName, res);
    },
    //下载账单
    async downloadXlsx(row) {
      let res = await warehouse_downloadFile(row.byBillFileId);
      req.exportFile(row.fileName, res);
    },
  },
};
</script>

<style lang="less" scoped>
</style>